﻿<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<RegisterPayload>" %>
<%@ Import Namespace="ActivateYourGlutes.Payloads.Account"%>

<asp:Content ID="registerTitle" ContentPlaceHolderID="TitleContent" runat="server">
    Register
</asp:Content>

<asp:Content ID="registerContent" ContentPlaceHolderID="MainContent" runat="server">
<script type="text/javascript">
jQuery.validator.setDefaults({
    debug: false,
    success: "valid"
});
</script>
<script type="text/javascript">
  $(document).ready(function() {
      $("#entryForm").validate({
          rules: {
              email: {
                  required: true,
                  email: true
              },
              username: {
                required: true
              },
              password: {
                required: true,
                minlength: <%= ViewData.Model.MinimumPasswordLength %>
              },
              confirmPassword: {
                required: true,
                minlength: <%= ViewData.Model.MinimumPasswordLength %>
              },
              dateOfBirth: {
                required: true
              }
          }
      });
      
      $("#dateOfBirth").datepicker({ defaultDate: 0, dateFormat: 'mm-dd-yy', changeMonth: true, changeYear: true, yearRange: '-100:+0' });
  });
</script>
    <h2>Create a New Account</h2>
    <p>
        Use the form below to create a new account. 
    </p>
    <p>
        Passwords are required to be a minimum of <%=Html.Encode(ViewData.Model.MinimumPasswordLength)%> characters in length.
    </p>
    <%= Html.ValidationSummary("Account creation was unsuccessful. Please correct the errors and try again.") %>

    <% using (Html.BeginForm(null, null, null, FormMethod.Post, new { id= "entryForm", AutoComplete="Off" })) { %>    
        <div>
            <%= Html.AntiForgeryToken() %>
            <fieldset>
                <legend>Account Information</legend>
                <p>
                    <label for="username">Username:</label>
                    <%= Html.TextBox("username") %>
                    <%= Html.ValidationMessage("username") %>
                </p>
                <p>
                    <label for="email">Email:</label>
                    <%= Html.TextBox("email") %>
                    <%= Html.ValidationMessage("email") %>
                </p>
                <p>
                    <label for="dateOfBirth">Date of Birth (mm-dd-yyyy):</label>
                    <%= Html.TextBox("dateOfBirth") %>
                    <%= Html.ValidationMessage("dateOfBirth") %>
                </p>
                <p>
                    <label for="password">Password:</label>
                    <%= Html.Password("password") %>
                    <%= Html.ValidationMessage("password") %>
                </p>
                <p>
                    <label for="confirmPassword">Confirm password:</label>
                    <%= Html.Password("confirmPassword") %>
                    <%= Html.ValidationMessage("confirmPassword") %>
                </p>
                <p>
                    <label for="confirmPassword">Preferred unit for measuring length:</label>
                    <%= Html.DropDownList("unitOfLength", ViewData.Model.UnitsOfLength) %>
                </p>
                <p>
                    <label for="confirmPassword">Preferred unit for measuring weight:</label>
                    <%= Html.DropDownList("unitOfWeight", ViewData.Model.UnitsOfWeight) %>
                </p>
                <p>
                    <label for="dateFormat1">Preferred date format:</label>
                    <%= Html.RadioButton("dateFormat", "month-day-year", true, new { id="dateFormat1"}) %> Month-Day-Year (<%= DateTime.Now.ToString("MM-dd-yyyy") %>)
                    <%= Html.RadioButton("dateFormat", "day-month-year", false, new { id = "dateFormat2" })%> Day-Month-Year (<%= DateTime.Now.ToString("dd-MM-yyyy") %>)
                </p>
                <p>
                    <%= Html.CheckBox("acceptTerms") %>
                    <label for="acceptTerms" class="inline" >Tick to accept the sites <%= Html.ActionLink("terms of service", MVC.Account.TermsAndConditions(), new { target = "_blank" })%> and <%= Html.ActionLink("privacy policy", MVC.Account.Privacy(), new { target = "_blank" })%>.</label>
                    <%= Html.ValidationMessage("acceptTerms") %>
                </p>
                <p>
                    <input type="submit" value="Register" />
                </p>
            </fieldset>
        </div>
    <% } %>
</asp:Content>
